/** * @license * Copyright 2018 JBoss Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { AaiServer, Document, OasDocument, OasOperation, SecurityRequirement, SecurityScheme } from "apicurio-data-models"; import { EntityEditor, EntityEditorEvent, IEntityEditorHandler } from "./entity-editor.component"; import { SelectionService } from "../../_services/selection.service"; export interface SecurityRequirementData { [key: string]: string[]; } export interface SecurityRequirementEditorEvent extends EntityEditorEvent { data: SecurityRequirementData; } export interface ScopeInfo { name: string; description: string; } export interface ISecurityRequirementEditorHandler extends IEntityEditorHandler { onSave(event: SecurityRequirementEditorEvent): void; onCancel(event: SecurityRequirementEditorEvent): void; } export declare class SecurityRequirementEditorComponent extends EntityEditor { protected selectionService: SelectionService; _expanded: any; protected model: SecurityRequirementData; anonEnabled: boolean; schemes: SecurityScheme[]; protected scopeCache: any; /** * C'tor. * @param selectionService */ constructor(selectionService: SelectionService); /** * Called to open the editor. * @param handler * @param context * @param server */ open(handler: ISecurityRequirementEditorHandler, context: OasDocument | OasOperation | AaiServer, requirement?: SecurityRequirement): void; /** * Initializes the editor's data model from a provided entity. * @param entity */ initializeModelFromEntity(entity: SecurityRequirement): void; /** * Initializes the editor's data model to an empty state. */ initializeModel(): void; /** * Creates an entity event specific to this entity editor. */ entityEvent(): SecurityRequirementEditorEvent; /** * Enables/disable anonymous access. * @param isAnon */ setAnon(isAnon: boolean): void; /** * Returns true if the editor is currently valid. */ isValid(): boolean; /** * Returns true if the given scheme is enabled. * @param scheme * @return */ isChecked(scheme: SecurityScheme): boolean; /** * Returns true only if the scheme is one that can be expanded. * @param scheme * @return */ canExpand(scheme: SecurityScheme): boolean; /** * Returns true if the given scheme is expanded. * @param scheme * @return */ isExpanded(scheme: SecurityScheme): boolean; /** * Called to toggle the expansion of a scheme. * @param scheme */ toggleExpansion(scheme: SecurityScheme): void; /** * Called to expand a scheme. * @param scheme */ expand(scheme: SecurityScheme): void; /** * Called to collapse a scheme. * @param scheme */ collapse(scheme: SecurityScheme): void; /** * Adds/removes the security scheme from the model. * @param scheme */ toggleSecurityScheme(scheme: SecurityScheme, enable?: boolean): void; /** * Returns the possible scopes for the given scheme. * @param scheme * @return */ scopes(scheme: SecurityScheme): ScopeInfo[]; /** * Returns true if the given scope is enabled/checked in the model. * @param scheme * @param scope * @return */ isScopeChecked(scheme: SecurityScheme, scope: string): boolean; /** * Toggles the enabled/checked status of a single scope for a given scheme. * @param scheme * @param scope * @param enable */ toggleScope(scheme: SecurityScheme, scope: string, enable?: boolean): void; /** * Finds all security schemes defined in the document. * @param document * @return */ findSchemes(document: Document): SecurityScheme[]; }